package com.spring.sunflower.common

import android.widget.ImageView
import android.widget.TextView
import androidx.core.content.ContextCompat
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.spring.sunflower.R
import com.spring.sunflower.bean.IncomeVideoChatBean
import com.spring.sunflower.util.AppUtils
import com.spring.sunflower.util.DateTimeUtils
import java.util.*

/**
 * Created by Kevin on 2021/8/28<br/>
 *
 * Describe:<br/>
 */
class IncomeVideoChatAdapter(layoutResId: Int, data: MutableList<IncomeVideoChatBean.DatasBean>) :
    BaseQuickAdapter<IncomeVideoChatBean.DatasBean, BaseViewHolder>(layoutResId, data) {
    override fun convert(holder: BaseViewHolder, item: IncomeVideoChatBean.DatasBean) {
        item?.let {
            holder.setText(
                R.id.tvTitle,
                "与${item.nickname}视频 时长${AppUtils.formatTime(item.durationTime.toInt())}"
            )
            val timeFormatText = DateTimeUtils.getTimeFormatText(Date((item.createTime).toLong()))
            holder.setText(R.id.tvTime, timeFormatText)
            val tvDetail = holder.getView<TextView>(R.id.tvDetail)
            tvDetail.setText("+${item.amount}")
            tvDetail.setTextColor(ContextCompat.getColor(context, R.color.colorPrimary))
            val ivMoney: ImageView = holder.getView(R.id.ivMoney)
            ivMoney.setImageResource(R.drawable.ic_income_diamond)
        }

    }
}